import { request } from './request';

// 获取用户信息列表
export function getUserDataList(queryInfo) {
  return request({
    method: 'GET',
    url: 'users',
    params: queryInfo,
  });
}

// 改变用户信息
export function ChangeUserInfo(userInfo) {
  return request({
    method: 'put',
    url: `users/${userInfo.id}/state/${userInfo.mg_state}`,
  });
}

// 添加用户
export function addUserInfo(addForm) {
  return request({
    method: 'POST',
    url: 'users',
    data: addForm,
  });
}

// 根据 ID 查询用户信息
export function queryUserInfo(id) {
  return request({
    method: 'GET',
    url: `users/${id}`,
  });
}

// 编辑用户提交
export function editUserInfoSub(editForm) {
  return request({
    method: 'put',
    url: `users/${editForm.id}`,
    data: {
      email: editForm.email,
      mobile: editForm.mobile,
    },
  });
}

// 删除用户提交
export function deleteUserInfoSub(id) {
  return request({
    method: 'delete',
    url: `users/${id}`,
  });
}

// 分配用户角色
export function allotUserRole(id, rid) {
  return request({
    method: 'put',
    url: `users/${id}/role`,
    data: {
      rid: rid,
    },
  });
}
